﻿using System;
using System.Collections.Generic;
using System.Linq; 
using NTTDATA.BEENChina.ResultCertification.Config;

namespace NTTDATA.BEENChina.ResultCertification.Checker.Date
{
    [Serializable]
    [VerfityAttribute(Id = "VerfityRq0210", Name = "入退院栏检证_1", CategoryType = EnumCategoryType.日期, Model = true)]
    public class VerfityRq0210:VerfityOneResult
    {



        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;

            List<string> hospitals = new List<string>();

            int hospitalResultIndex =
             ChildImageObject.CategorySetting.DataFormat.Split('/').ToList().IndexOf("tx");
            

            foreach (var rowResult in result)
            {

                if (rowResult.Count >= 2)
                {
                    string colResult1 = rowResult[0];
                    //string hos;

                    if (EmptyResultCount(colResult1) == 1)
                    {
                        return false;
                    }

                    if (colResult1.Split('/').Length > hospitalResultIndex)
                    {
                        
                        hospitals.Add(

                            new Split.SplitEntryResult(ChildImageObject.CategorySetting.DataFormat, colResult1).GetHospital()
                            );
                    }


                    string colResult2 = rowResult[1];
                    
                    if (colResult2.Split('/').Length > hospitalResultIndex)
                    {

                        hospitals.Add(

                            new Split.SplitEntryResult(ChildImageObject.CategorySetting.DataFormat, colResult2).GetHospital()
                            );
                    } 
 

                }

                
                if (hospitals.Count>1 &&   String.IsNullOrEmpty(hospitals[0]) && !string.IsNullOrEmpty(hospitals[1]))
                {
                    bresult = true;
                }

                if (bresult)
                        break;

                }

         
            
  

            if (bresult)
            {
                System.Console.WriteLine("VerfityRq0210");
            }

            return bresult;   
        }
         

        

    }
}